Copyright: Copyright ©1995 I.D.E Software


Contents
 ChkList Control

  Properties	Methods	Events

Description

The ChkList control displays a list of items from which the user can select one or more items. If the number of items in the list exceeds that which can be displayed a scrollbar is automatically displayed, allowing the user to scroll through the list. Each item in the list can contain a picture as well as text, along with any checked/unchecked picture.

The following diagram shows the typical layout of the ChkList control.

To Check/Uncheck an item in the list the user can either Double-click the item or press Enter/Spacebar when the item is selected.

Distribution Note

When you create and distribute applications which use the ChkList control, you should install the CHKLIST.VBX file in the customers Microsoft Windows \SYSTEM subdirectory.

Copyright ©1995 I.D.E Software

All rights reserved worldwide.

Microsoft is a registered trademark and Windows and Visual Basic are registered trademarks of Microsoft Corporation in the USA and other countries.


Properties

The Properties for this control are listed in the following table. Properties which are specific to the ChkList control, or require special consideration when using them with it have been marked with an asterisk (*). For information on the remaining properties, please consult your Visual Basic documentation.

Align	hWnd	Parent

BackColor	Index	*PictureAlign

BorderStyle	*ItemBackColor	*PictureChecked

DragIcon	*ItemChecked	*PictureHeight

DragMode	ItemData	*PictureUnchecked

Enabled	*ItemFontIndex	*PictureWidth

FontBold	*ItemForeColor	*RightMargin

FontItalic	*ItemPictureIndex	*Spacing

FontName	*ItemText	TabIndex

FontSize	Left	Tag

FontStrikethru	*LeftMargin	*TextAlign

FontUnderline	ListCount	Top

ForeColor	ListIndex	TopIndex

Height	MousePointer	Visible

HelpContextID	Name	Width

Resource Array Properties, see Font, Picture Resource Arrays

*iFontBold	*iPicture

*iFontItalic	*iPictureWidth

*iFontName	*iPictureHeight

*iFontSize

*iFontStrikethru

*iFontUnderline


Methods

The Methods for this control are listed in the following table. For further information, please consult your Visual Basic documentation.

AddItem	Move	SetFocus

Clear	Refresh	ZOrder

Drag	RemoveItem


Events

The Events for this control are listed in the following table. Events which are specific to the ChkList control have been marked with an asterisk (*). For information on the remaining events, please consult your Visual Basic documentation.

Click	*ItemChecked	LostFocus

DblClick	*ItemUnchecked	MouseDown

DragDrop	KeyDown	MouseMove

DragOver	KeyPress	MouseUp

GotFocus	KeyUp


ItemBackColor, ItemForeColor Properties

Description

These properties are used to set or get the background or foreground color of an individual item in the list.

Usage

[form.]ChkList.ItemBackColor(index)[ = color]

[form.]ChkList.ItemForeColor(index)[ = color]

Remarks

If the specified index does not exist, an Invalid Property Array Index error will be generated.

Data Type

Long


Font, Picture Resource Arrays

Description

Resource Arrays are used to reduce the number of system resources (handles) ChkList uses. You firstly setup the font/picture resource using the iFont... or iPicture... properties and then use the ItemFontIndex and ItemPictureIndex properties to set which resource the item will use. When the control is destroyed all items in the resource arrays are removed.

Example:

Sub Form_Load ()

'setup a new font resource in index 0

ChkList1.iFontBold(0) = True

ChkList1.iFontName(0) = "MS sans Serif"

ChkList1.iFontSize(0) = 9.75

'setup a new picture resource in index 0

ChkList1.iPicture(0) = LoadPicture("\WINDOWS\CASTLE.BMP")

'add some items to the list

ChkList1.AddItem "Item 0"

ChkList1.AddItem "Item 1"

ChkList1.AddItem "Item 2"

'let item 1 use font resource 0

ChkList1.ItemFontIndex(1) = 0

'let items 1 & 2 use picture resource 0

ChkList1.ItemPictureIndex(1) = 0

ChkList1.ItemPictureIndex(2) = 0

End Sub


ItemChecked Property

Description

The ItemChecked property is used to set or get the current checked state of an individual item in the list.

Usage

[form.]ChkList.ItemChecked(index)[ = {True | False} ]

Remarks

If the specified index does not exist, an Invalid Property Array Index error will be generated.

Data Type

Integer (Boolean)


ItemFontIndex, ItemPictureIndex Properties

Description

These properties are used to set or get the font or picture resource array index of an individual item in the list.

Usage

[form.]ChkList.ItemFontIndex(index)[ = fontindex]

[form.]ChkList.ItemPictureIndex(index)[ = pictureindex]

Remarks

If the specified index does not exist, an Invalid Property Array Index error will be generated.

If the specified fontindex/pictureindex  does not exist if the appropriate Resource Array, an Invalid Property Value error will be generated.

If the specified fontindex = -1 the system will revert to using the default font specified by the standard font properties.

If the specified pictureindex = -1 the system will not display a picture.

Data Type

Integer

see also

Font, Picture Resource Arrays


ItemChecked, ItemUnchecked Events

Description

These events occur after an item has been checked or unchecked, either by setting the ItemChecked property, or by the user pressing Enter/Spacebar when the item is selected or Double-clicking an item in the list.

Syntax

Sub chklist_ItemChecked([index As Integer,] I As Integer )

Sub chklist_ItemUnchecked([index As Integer,] I As Integer )

Remarks

These events pass I,  the index of the item checked/unchecked.

If the event has been caused by the user, the event will occur after the standard DblClick or KeyDown event.


ItemText Property

Description

The ItemText property is used to set or get the text of an individual item in the list.

Usage

[form.]ChkList.ItemText(index)[ = text]

Remarks

If the specified index does not exist, an Invalid Property Array Index error will be generated.

If the length of the specified text is greater than 256 characters, an Invalid Property Value error will be generated.

Data Type

String


LeftMargin, RightMargin Properties

Description

These properties are used to set or get the left or right margins.

Usage

[form.]ChkList.LeftMargin[ = margin]

[form.]ChkList.RightMargin[ = margin]

Remarks

If the specified margin is greater than 30, an Invalid Property Value error will be generated.

Data Type

Integer


PictureAlign, Text Align Properties

Description

These properties are used to set or get the vertical picture/text alignment.

Usage

[form.]ChkList.PictureAlign[ = align]

[form.]ChkList.TextAlign[ = align]

Remarks

The following table lists the valid settings for these properties.

Setting	Description

0	Top

1	Middle

2	Bottom

Data Type

Integer (enumerated)


iFontBold, iFontItalic, iFontName, iFontSize, iFontStrikethru, iFontUnderline Properties

Description

These properties are used to set or get the attributes of an individual entry in the Font Resource Array.

Usage

[form.]ChkList.iFontBold(index)[ = {True | False} ]

[form.]ChkList.iFontItalic(index)[ = {True | False} ]

[form.]ChkList.iFontName(index)[ = name]

[form.]ChkList.iFontSize(index)[ = size]

[form.]ChkList.iFontStrikethru(index)[ = {True | False} ]

[form.]ChkList.iFontUnderline(index)[ = {True | False} ]

Remarks

If the specified index does not exist it will be created.

Data Types

Integer (Boolean)	iFontBold, iFontItalic, iFontStrikeThru, iFontUnderline

String	iFontName

Integer	iFontSize


PictureChecked, PictureUnchecked Properties

Description

These properties are used to set or get the pictures associated with checked/unchecked items in the list.

Usage

[form.]ChkList.PictureChecked[ = picture]

[form.]ChkList.PictureUnchecked[ = picture]

Remarks

The PictureChecked and PictureUnchecked properties can display either bitmap files (.BMP), icon files (.ICO) or nothing.

If you don't want to display any pictures, you can set both of these properties to (None) and use another visual effect to indicate a checked/unchecked state, for instance change the ItemBackColor, ItemForeColor or ItemFontIndex.

Data Type

Integer

see also

Pictures, Picture Heights and Picture Widths


Spacing Property

Description

The Spacing property is used to set or get the horizontal spacing between the pictures and text.

Usage

[form.]ChkList.Spacing[ = spacing]

Remarks

If the specified spacing is greater than 30, an Invalid Property Value error will be generated.

Data Type

Integer


PictureHeight, PictureWidth Properties

Description

These properties are used to set or get the height/width of the checked and unchecked pictures.

Usage

[form.]ChkList.PictureHeight[ = height]

[form.]ChkList.PictureWidth[ = width]

Remarks

If the specified height/width is greater than 256, an Invalid Property Value error will be generated.

Data Type

Integer

see also

Pictures, Picture Heights and Picture Widths


iPicture, iPictureHeight, iPictureWidth Properties

Description

These properties are used to set or get the attributes of an individual entry in the Picture Resource Array.

Usage

[form.]ChkList.iPicture(index)[ = picture]

[form.]ChkList.iPictureHeight(index)[ = height]

[form.]ChkList.iPictureWidth(index)[ = width]

Remarks

If the specified index does not exist it will be created.

The specified picture can be either a bitmap file (.BMP) or an icon file (.ICO).

If the specified height/width is greater than 256, an Invalid Property Value error will be generated.

Data Type

Integer

see also

Pictures, Picture Heights and Picture Widths


Pictures, Picture Heights and Picture Widths

Description

ChkList supports both icon files (.ICO) and bitmap files (.BMP) for all pictures. However there are some things to remember when using them:

Bitmaps

If you use a bitmap image, ChkList samples the first pixel (0,0) in the image and uses this as the transparent color. It performs a surface fill from all four corners before displaying the image. This may not be acceptable in some cases and therefore the image will either have to have a complete border of a different color or convert the image to an icon (if possible).

Picture Heights and Widths

The PictureHeight, PictureWidth, iPictureHeight and iPictureWidth properties allow you to specify how much of the given picture will be displayed. For instance, your picture may be 40 * 40 pixels but you only wish to display 20 * 20, you would simply set the appropriate height and width properties to 20.

The other reason for supporting these properties is that icon sizes are fixed, and therefore you may wish to reduce the height and width to only show part of the icon and take advantage of icon transparency.